home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Power 1997 December
/
MACPOWER-1997-12.ISO.7z
/
MACPOWER-1997-12.ISO
/
AMUG
/
PROGRAMMING
/
Raven 1.2.sit
/
Raven 1.2
/
Source
/
Foundation
/
OS
/
ZExitAction.cpp
< prev
next >
Wrap
Text File
|
1997-07-27
|
2KB
|
93 lines
/*
* File: ZExitAction.cpp
* Summary: Mixin for objects that need to do cleanup when the app exists abnormally.
* Written by: Jesse Jones
*
* Copyright ゥ 1997 Jesse Jones.
* For conditions of distribution and use, see copyright notice in ZTypes.h
*
* Change History (most recent first):
*
* <2> 7/27/97 JDJ List is accessed through a function instead of a static.
* <1> 4/13/97 JDJ Created
*/
#include <ZExitAction.h>
#include <Set.h>
#include <ZDebug.h>
//-----------------------------------
// Types
//
typedef set<MExitAction*, less<MExitAction*>, allocator<MExitAction*> > ZActionList;
// ===================================================================================
// Internal Functions
// ===================================================================================
//---------------------------------------------------------------
//
// GetExitList
//
//---------------------------------------------------------------
static ZActionList& GetExitList()
{
static ZActionList actions;
return actions;
}
#pragma mark -
// ===================================================================================
// class MExitAction
// ===================================================================================
//---------------------------------------------------------------
//
// MExitAction::~MExitAction
//
//---------------------------------------------------------------
MExitAction::~MExitAction()
{
ZActionList::iterator iter = GetExitList().find(this);
ASSERT(iter != GetExitList().end());
GetExitList().erase(iter);
}
//---------------------------------------------------------------
//
// MExitAction::MExitAction
//
//---------------------------------------------------------------
MExitAction::MExitAction()
{
ASSERT(GetExitList().find(this) == GetExitList().end());
GetExitList().insert(this);
}
//---------------------------------------------------------------
//
// MExitAction::DoExitActions [static]
//
//---------------------------------------------------------------
void MExitAction::DoExitActions()
{
ZActionList::iterator iter = GetExitList().begin();
while (iter != GetExitList().end()) {
MExitAction* action = *iter++;
action->OnAbnormalExit();
}
}